﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Model;
using DuncanDAL;
using BLL.BaseDictionaryService;

namespace BLL.EarningService
{
    /// <summary>
    /// 查询所有的收入记录
    /// </summary>
    public class QueryEarningRecordTransaction :ICommand
    {
        private IList<T_EarningRecordsObject> resultList;

        public IList<T_EarningRecordsObject> ResultList
        {
            get { return resultList; }
        }

        #region ICommand 成员

        public void Execute()
        {
            QueryUsersTransaction objQueryUsersTransaction = new QueryUsersTransaction();
            objQueryUsersTransaction.Execute();
            QueryEarningCategoryTransaction objQueryEarningCategoryTransaction = new QueryEarningCategoryTransaction();
            objQueryEarningCategoryTransaction.Execute();


            EarningRecordsDataService objEarningRecordsDataService = new EarningRecordsDataService();
            resultList = objEarningRecordsDataService.QueryAll();
            foreach (T_EarningRecordsObject item in resultList)
            {
                item.EarningCategory = objQueryEarningCategoryTransaction.ResultList.SingleOrDefault(x => x.Db_OID == item.Db_EarningCategory).Db_EarningCategory;
                item.EarningUser = objQueryUsersTransaction.Users.SingleOrDefault(x => x.Db_OID == item.Db_EarningObject).Db_NickName;
            }
        }

        #endregion
    }
}
